<!--
 * Description: SupplyCloud修改页面
 * Company: 联宝（合肥）电子科技有限公司
 * Author: Dongxu.Ni
 * Date: 2020/04/14 02:52
-->

<template>
  <div v-loading="isRequesting">
    <!--数据表单-->
    <el-form label-width="150px" :model="formData" size="mini">
      <el-row>
        <!--pn-->
        <el-col :span="12">
          <el-form-item label="PN">
            <el-input v-model="formData.pn" clearable />
          </el-form-item>
        </el-col>

        <!--vendor-->
        <el-col :span="12">
          <el-form-item label="vendor">
            <el-input v-model="formData.vendor" clearable />
          </el-form-item>
        </el-col>

        <!--sourceCode-->
        <el-col :span="12">
          <el-form-item label="SourceCode">
            <el-input v-model="formData.sourceCode" clearable />
          </el-form-item>
        </el-col>

        <!--actualGr-->
        <el-col :span="12">
          <el-form-item label="ActualGr">
            <el-input-number
              v-model="formData.actualGr"
              clearable
              controls-position="right"
              :min="1"
            />
          </el-form-item>
        </el-col>

        <!--outlookGr-->
        <el-col :span="12">
          <el-form-item label="OutlookGr">
            <el-input-number
              v-model="formData.outlookGr"
              v-blur:outlookGr="formData"
              clearable
              controls-position="right"
              :min="1"
            />
          </el-form-item>
        </el-col>

        <!--fiscalYear-->
        <el-col :span="12">
          <el-form-item label="FiscalYear">
            <el-input-number
              v-model="formData.fiscalYear"
              clearable
              controls-position="right"
              :min="1"
            />
          </el-form-item>
        </el-col>

        <!--month-->
        <el-col :span="12">
          <el-form-item label="Month">
            <el-input v-model="formData.month" clearable />
          </el-form-item>
        </el-col>

        <!--mrpOutlookGr-->
        <el-col :span="12">
          <el-form-item label="MrpOutlookGr">
            <el-input
              v-model="formData.mrpOutlookGr"
              clearable
              controls-position="right"
              :min="1"
            />
          </el-form-item>
        </el-col>

        <!--mrpOutlookGrNumber-->
        <el-col :span="12">
          <el-form-item label="MrpOutlookGrNumber">
            <el-input
              v-model="formData.mrpOutlookGrNumber"
              clearable
              controls-position="right"
              :min="1"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span style="display: block;text-align: center;margin-top: 5px">
      <!--取消按钮-->
      <el-button size="medium" @click="cancel">{{ $t('button.cancel') }}</el-button>
      <!--保存按钮-->
      <el-button size="medium" type="primary" @click="save">{{ $t('button.save') }}</el-button>
    </span>
  </div>
</template>

<script>
import { monthOutlookActGREdit } from '@/api/spendingSaving/spendingSaving'

export default {
  name: 'MonthGREdit',
  props: {
    inputData: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      isRequesting: false,
      formData: {}
    }
  },
  created() {
    this.pageDataInit()
  },
  methods: {
    pageDataInit() {
      // 将props传入的值复制给formData的值
      this.formData = {
        ...this.inputData
      }
    },
    async save() {
      console.log(this.formData)
      try {
        this.isRequesting = true
        await monthOutlookActGREdit(this.formData, { msgSuccess: true, msgError: true })
        this.$emit('save')
      } catch (error) {
        console.log(error)
      } finally {
        this.isRequesting = false
      }
    },
    cancel() {
      this.$emit('cancel')
    }
  }
}
</script>

<style scoped></style>
